import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yt_devops/components/app_bar/app_bar_widget.dart';
import 'package:yt_devops/components/gaps.dart';
import 'package:yt_devops/components/yt_text_style.dart';
import 'package:yt_devops/pages/devices/device_tab/device_detail/new_air_cooling_page/component/soc_and_electricity_chart.dart';
import 'package:yt_devops/components/my_gesture_detector.dart';
import 'package:yt_devops/pages/site/site_setting/siet_elec_price_setting/site_mains_elec_detail/keep_aliver_wrapper.dart';
import 'package:yt_devops/pages/site/site_statis_data/show_full_screen_btn.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/routers/router_path.dart';
import 'package:yt_devops/styles/styles.dart';
import 'charge_order_detail_controller.dart';

class ChargeOrderDetailPage extends GetView<ChargeOrderDetailController> {
  const ChargeOrderDetailPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget.withRightActions(ResKey.orderDetail.tr),
      body: GetBuilder<ChargeOrderDetailController>(
          builder: (_) => ListView(children: [
                Gaps.vGap10,
            Container(
                height: 290 + 30 + 40,
                color: Colors.white,
                child:  Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      alignment: Alignment.centerLeft,
                      margin: EdgeInsets.only(
                        left: 16.w,top: 16
                      ),
                      height: 26,
                      child: Text(
                        ResKey.socAndElectric.tr,
                        style: ytTextStyle(
                            color: Colour.mainTextColor,
                            fontSize: 18,
                            fontWeight: FontWeight.w500),
                      ),
                    ),
                    Container(
                        height: 40,
                        color: Colors.white,
                        alignment: Alignment.center,
                        child: Row(
                          children: [
                            Spacer(),
                            ShowFullScreenBtn(onTap: (){
                                Get.toNamed(RouterPath.socElectricityFullChart,arguments:
                                {
                                  'soc':controller.soc,'chargedElectricity':controller.chargedElectricity,
                                  'needVoltage':controller.needVoltage,'outVoltage':controller.outVoltage,
                                  'needCurrent':controller.needCurrent,'outCurrent':controller.outCurrent,
                                });
                            },
                            )
                          ],
                        )),
                    Container(
                        height: 270, color: Colors.white, child: KeepAliveWrapper(SocAndElectricity(
                       controller.soc,controller.chargedElectricity,controller.needVoltage,
                      controller.outVoltage,controller.needCurrent,controller.outCurrent,
                    ))),
                  ],
                )),
            Gaps.vGap10,
                Container(
                  // height: 53 + 372,
                  color: Colors.white,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        alignment: Alignment.centerLeft,
                        margin: EdgeInsets.only(
                          left: 16.w,
                        ),
                        height: 53,
                        child: Text(
                          ResKey.baseInfo.tr,
                          style: ytTextStyle(
                              color: Colour.mainTextColor,
                              fontSize: 18,
                              fontWeight: FontWeight.w500),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.only(left: 16.w,right: 16.w),
                        height: 1,color: Colour.dividerColor,
                      ),
                      SizedBox(
                        height:controller.titleList.length * 50 ,
                          child: ListView.builder(
                            physics: const NeverScrollableScrollPhysics(),
                        padding: EdgeInsets.zero,
                        itemBuilder: (BuildContext context, int index) {
                          return _rowItem(controller.titleList[index],controller.valueList[index]);
                        },
                        itemCount: controller.titleList.length,
                      ))
                    ],
                  ),
                ),

              ])),
    );
  }

  _rowItem(String title, String value) {
    return SizedBox(
      height: 50,
      child:Column(
        children: [
          SizedBox(
            height: 49,
            child: Row(
              children: [
                Container(
                  alignment: Alignment.centerLeft,
                  margin:  EdgeInsets.only(left: 16.w),
                  child:
                  Text(
                    title,
                    style: ytTextStyle(
                        color: Colour.otherTextColor,
                        fontSize: 14,
                        fontWeight: FontWeight.normal),
                  ),
                ),
                Spacer(),
                Container(
                  alignment: Alignment.centerRight,
                  margin:  EdgeInsets.only(right: 16.w),
                  child:
                  Text(
                    value,
                    style: ytTextStyle(
                        color: Colour.mainTextColor,
                        fontSize: 14,
                        fontWeight: FontWeight.normal),
                  ),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(left: 16.w,right: 16.w),
            height: 1,color: Colour.dividerColor,
          )
        ],
      ),
    );
  }
}
